#include <QCoreApplication>
#include<iostream>
#include<QDebug>
using namespace std;
class car
{ public:
    virtual void productcar()=0;
    virtual ~car(){}
};
class benz:public car
{
public:
    void productcar(){
      qDebug()<<"奔驰车";
    }
};
class byd:public car
{
public:
    void productcar()
    {
                          qDebug()<<"比亚迪";
    }
};

class simpleFactory
{
public:
    car* createcar(string type)
    { if(type=="byd")
        {
            return new byd();
        }
        else if(type=="benz")
        {
            return new benz();
        }


    }
};



int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // Set up code that uses the Qt event loop here.
    // Call a.quit() or a.exit() to quit the application.
    // A not very useful example would be including
    // #include <QTimer>
    // near the top of the file and calling
    // QTimer::singleShot(5000, &a, &QCoreApplication::quit);
    // which quits the application after 5 seconds.

    // If you do not need a running Qt event loop, remove the call
    // to a.exec() or use the Non-Qt Plain C++ Application template.
    car* newcar;
    simpleFactory* factor=new simpleFactory();
    newcar=factor->createcar("byd");
    newcar->productcar();
    delete newcar;
    newcar=factor->createcar("benz");
    newcar->productcar();
    delete newcar;
    return a.exec();
}
